home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / scrn.c < prev    next >
Text File  |  1985-06-03  |  3KB  |  115 lines

  1. /*************************************************************************
  2. scrn - function allows colors and/or attributes of color display to be set
  3. when using ansi.sys on dos v2.0.
  4.  
  5. scrn parm [parm2]
  6.  
  7. where parm1 and 2 may be the name of a color or attribute as shown below.
  8. Only lower case commands are checked for.
  9.  
  10. written by Rex Jaeschke of Rockville, MD. 1983 (301) 251-8987
  11. compiler used DeSmet v2.2
  12. *************************************************************************/
  13.  
  14. #define ESCAPE 27
  15.  
  16. #define RESET 0
  17. #define BOLD 1
  18. #define UNDERSC 4
  19. #define BLINK 5
  20. #define REVERSE 7
  21. #define INVIS 8
  22.  
  23. #define FBLACK 30        /* foreground colors */
  24. #define FRED 31
  25. #define FGREEN 32
  26. #define FYELLOW 33
  27. #define FBLUE 34
  28. #define FMAGENTA 35
  29. #define FCYAN 36
  30. #define FWHITE 37
  31.  
  32. #define BBLACK 40        /* background colors */
  33. #define BRED 41
  34. #define BGREEN 42
  35. #define BYELLOW 43
  36. #define BBLUE 44
  37. #define BMAGENTA 45
  38. #define BCYAN 46
  39. #define BWHITE 47
  40.  
  41. main (argc,argv)
  42. int argc;
  43. char *argv[];
  44. {
  45.     if (argc < 2) {
  46.         printf ("Must have at least one parameter.\n");
  47.         return;
  48.     }
  49.     else
  50.     {
  51.         if (strcmp (argv[1],"black") == 0)
  52.             scr_sgr (FBLACK);
  53.         else if (strcmp (argv[1],"red") == 0)
  54.             scr_sgr (FRED);
  55.         else if (strcmp (argv[1],"green") == 0)
  56.             scr_sgr (FGREEN);
  57.         else if (strcmp (argv[1],"yellow") == 0)
  58.             scr_sgr (FYELLOW);
  59.         else if (strcmp (argv[1],"blue") == 0)
  60.             scr_sgr (FBLUE);
  61.         else if (strcmp (argv[1],"magenta") == 0)
  62.             scr_sgr (FMAGENTA);
  63.         else if (strcmp (argv[1],"cyan") == 0)
  64.             scr_sgr (FCYAN);
  65.         else if (strcmp (argv[1],"white") == 0)
  66.             scr_sgr (FWHITE);
  67.         else if (strcmp (argv[1],"reset") == 0)
  68.             scr_sgr (RESET);
  69.         else if (strcmp (argv[1],"bold") == 0)
  70.             scr_sgr (BOLD);
  71.         else if (strcmp (argv[1],"undersc") == 0)
  72.             scr_sgr (UNDERSC);
  73.         else if (strcmp (argv[1],"blink") == 0)
  74.             scr_sgr (BLINK);
  75.         else if (strcmp (argv[1],"reverse") == 0)
  76.             scr_sgr (REVERSE);
  77.         else if (strcmp (argv[1],"invis") == 0)
  78.             scr_sgr (INVIS);
  79.         else if (strcmp (argv[1],"same") != 0)
  80.             printf ("First parameter is invalid.\n");
  81.     }
  82.     if (argc >= 3) {
  83.         if (strcmp (argv[2],"black") == 0)
  84.             scr_sgr (BBLACK);
  85.         else if (strcmp (argv[2],"red") == 0)
  86.             scr_sgr (BRED);
  87.         else if (strcmp (argv[2],"green") == 0)
  88.             scr_sgr (BGREEN);
  89.         else if (strcmp (argv[2],"yellow") == 0)
  90.             scr_sgr (BYELLOW);
  91.         else if (strcmp (argv[2],"blue") == 0)
  92.             scr_sgr (BBLUE);
  93.         else if (strcmp (argv[2],"magenta") == 0)
  94.             scr_sgr (BMAGENTA);
  95.         else if (strcmp (argv[2],"cyan") == 0)
  96.             scr_sgr (BCYAN);
  97.         else if (strcmp (argv[2],"white") == 0)
  98.             scr_sgr (BWHITE);
  99.         else if (strcmp (argv[2],"same") != 0)
  100.             printf ("Second parameter is invalid.\n");
  101.     }
  102.     if (argc > 3)
  103.         printf ("Too many parameters.\n");
  104. }
  105.  
  106. scr_sgr (attrib)
  107. int attrib;
  108. {
  109.     printf ("%c[%dm",ESCAPE,attrib);
  110. }
  111. (argc > 3)
  112.         printf ("Too many parameters.\n");
  113. }
  114.  
  115. scr_sgr (attri